<core:SET width='200'>
<core:SET content="site_layout">

<core:SET title="Rotating banners management">
<core:WRAP file="/adm/adm.layout.html" placeholder="Content">

<core:include file="/adm/inc/inc.adm.tabs.html">

<script type="text/javascript" src="/{$#app_name}/FCKeditor/fckeditor.js"></script>
    <script language="Javascript">

    // Gets a element by its Id. Used for shorter coding.
function GetE( elementId )
{
	return document.getElementById( elementId )  ;
}

function ShowE( element, isVisible )
{
	if ( typeof( element ) == 'string' )
		element = GetE( element ) ;
	element.style.display = isVisible ? '' : 'none' ;
}

function SetAttribute( element, attName, attValue )
{
	if ( attValue == null || attValue.length == 0 )
		element.removeAttribute( attName, 0 ) ;			// 0 : Case Insensitive
	else
		element.setAttribute( attName, attValue, 0 ) ;	// 0 : Case Insensitive
}

function GetAttribute( element, attName, valueIfNull )
{
	var oAtt = element.attributes[attName] ;

	if ( oAtt == null || !oAtt.specified )
		return valueIfNull ? valueIfNull : '' ;

	var oValue = element.getAttribute( attName, 2 ) ;

	return ( oValue == null ? valueIfNull : oValue ) ;
}



      function AddImage() {

        var width = screen.width*0.7;
		var height = screen.height*0.7;

		var iLeft = (screen.width  - width) / 2 ;
        var iTop  = (screen.height - height) / 2 ;

        var sOptions = "toolbar=no,status=no,resizable=yes,dependent=yes" ;
		sOptions += ",width=" + width  ;
		sOptions += ",height=" + height ;
		sOptions += ",left=" + iLeft ;
		sOptions += ",top=" + iTop ;

		var path = '/{$#app_name}/FCKeditor/editor/filemanager/browser/default/browser.html?Type=Image&Connector=connectors/php/connector.php';
   		window.open(path, "FCKBrowseWindow", sOptions ) ;
      }

      function SetUrl( fileUrl ) {
          	document.forms[0].image.value=fileUrl;
          	var picture = GetE('image_url');
          	if (picture) SetAttribute( picture, 'src', fileUrl );
            var size_element =  GetE('size');
          	if (size_element) size_element.style.visibility = 'hidden';
      }

      function OnBannerImage() {
      	var eUrl = GetE('url');
      	var eAlt = GetE('alt');
      	var eScript = GetE('script');
      	var eImage = GetE('image');
      	if (eUrl) eUrl.disabled = false;
        if (eAlt) eAlt.disabled = false;
        if (eImage) eImage.disabled = false;
        if (eScript) eScript.disabled = true;

      }

       function OnBannerScript() {
      	var eUrl = GetE('url');
      	var eAlt = GetE('alt');
      	var eScript = GetE('script');
      	var eImage = GetE('image');
      	if (eUrl) eUrl.disabled = true;
        if (eAlt) eAlt.disabled = true;
        if (eImage) eImage.disabled = true;
        if (eScript) eScript.disabled = false;
      }

      function Refresh() {
      	var eSource = GetE('source');
      	if (eSource) {
      		if (eSource.value == 1) OnBannerScript();
      		else OnBannerImage();
      	}
      }

</script>


<h1 align="center"> </h1>


<form id="RotationForm" name="RotationForm" method="post" action="" runat="server">
<input name="id" type="hidden" id="id" runat="server">
<input name="page" type="hidden" id="page" runat="server">
<hr>
<core:optional for="msg">
	<span class="message" runat="server"> {$msg} </span>
</core:optional>
<table width="100%" border="0" align="center" cellspacing="2" cellpadding="3">
    <tr align="left">
    	<td class="whiteheader_center">
    		<core:optional for="id">
    			Edit the rotating banner (ID: {$id})
            </core:optional>
            <core:default for="id">
            	Create a rotating banner
            </core:default>
         </td>
         <td class="whiteheader">
            <a href="/{$#app_name}/myprofile/index.htm"> My Profile </a> &nbsp;
           	<html:link url="/">All rotating banners </html:link>
          </td>
     </tr>

    <core:default for="supress_errors">
    <ERRORSUMMARY id='Summary' runat="server">
        <tr valign="top">
          <td width="{width}">Errors: &nbsp;</td>
          <td class="left">
          	<FONT COLOR="RED">
          		<list:ITEM> {$ErrorMessage} &nbsp; </list:ITEM>
          	</FONT>
          </td>
        </tr>
     </ERRORSUMMARY>
     </core:default>

     <tr>
     	<td class="small" colspan="2">
     		<core:optional for="id">
     			Enter your changes to the information below to edit an existing content item.
     			When you are finished, press the Save button.
            </core:optional>
     	</td>
     </tr>





     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="headline" runat="server">Name of the banner</label>
       </td>
       <td class="form_field">
         <input name="headline" type="text" id="headline" size="50" runat="server">
         <span class="small"> 50 characters limit </span>
       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="source" runat="server">Type of the banner</label>
       </td>
       <td class="form_field">
         <INPUT TYPE="RADIO" NAME="source" id="source0" value="0" runat="server" onclick="javascript:OnBannerImage();">Uploaded Image
         <INPUT TYPE="RADIO" NAME="source" id="source1" value="1" runat="server" onclick="javascript:OnBannerScript();">Banner Exchange script
       </td>
     </tr>



      <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="url" runat="server">Target URL</label>
       </td>
       <td class="form_field">
         <input name="url" type="text" id="url" size="64" runat="server">
         <span class="small"> 64 characters limit </span>
       </td>
     </tr>


     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="alt" runat="server">ALT Text</label>
       </td>
       <td class="form_field">
         <input name="alt" type="text" id="alt" size="64" runat="server">
         <span class="small"> 64 characters limit </span>
       </td>
     </tr>

      <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="script" runat="server">Banner exchange script:</label>
       </td>
       <td class="form_field">
         <textarea id="script" name="script" cols="60" rows="8" runat="server">
       	 </textarea>
       </td>
     </tr>

     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="priority" runat="server">Priority</label>
       </td>
       <td class="form_field">
         <input name="priority" type="text" id="priority" size="2" runat="server">
         <span class="small"> number from 0 to 99 </span>
       </td>
     </tr>


     <tr valign="top">
       <td class="form_label" width="{$width}">
      	 <label for="small_picture" runat="server">
      	 	Banner Image:
      	 </label>
       </td>
       <td class="form_field">
         <table>
         <tr>
         	<td>
            	<core:optional for="image">
           			<a id="a_picture_url" name="a_picture_url" href="{$image}">
             			<img id="image_url" name="image_url" src="{$image}" border="0"/>
           			</a> <br>
           			<div id="size" name="size">
           			  Size: {$image_width}*{$image_height} <br>
           			</div>
                </core:optional>

                <core:default for="image">
                   <img id="image_url" name="image_url" src="/{$#app_name}/images/1x1.gif" border="0"/>
           		   <br>
                </core:default>

                <input name="image" type="text" id="image" runat="server" size="64">
                <BUTTON name="add_image" style="width:150;" class="form_button" onclick="AddImage();">Add/Change image</BUTTON>
         	</td>
            <td>
            </td>
         </tr>
         </table>
       </td>
     </tr>


     <tr>
      <td class="whiteheader_center" colspan="2">&nbsp;</td>
     </tr>

	 <tr>
      <td>&nbsp;</td>
      <td class="form_field">

      		<core:default for="id">
      			<input type="submit" name="create" value="Create" runat="server">
            </core:default>
            <core:optional for="id">
      			<input type="submit" name="save" value="Save" runat="server">
                <!--<input type="submit" name="delete" value="Delete" runat="server">-->
            </core:optional>
            <input type="submit" name="clean" value="Clean" runat="server">
            <input type="submit" name="list" value="Back to rotating banners" runat="server">

      </td>
</tr>

</table>
</form>

 <script language="Javascript">
 	Refresh();
 </script>